package com.adu.springbootdemo.conf;

import com.adu.springbootdemo.Interceptor.IpInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MvcConfigurer implements WebMvcConfigurer {
    // 拦截器
    public void addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(new IpInterceptor());
    }
    // 跨域访问配置
    @Override
    public void addCorsMappings(CorsRegistry registry){
        // 运行所以请求跨域
        registry.addMapping("/**");
    }

}
